﻿var UrlJump = {};
/**
* 随机数
*/
UrlJump.getSerialNumber = function () {
    var serial = Math.random() * 9999;
    return "serial=" + serial;
};

var numPublic = {
    sqlInt: 2147483647
}
var tempPublicVal_public = {
    maxzIndex: 9996,
    layerIndex: 1,
    wins: []
}

function GetTop() { return document.body.scrollTop || document.documentElement.scrollTop }
function GetWidth() { return self.innerWidth || document.documentElement.clientWidth; }
function GetHeight() { return self.innerHeight || document.documentElement.clientHeight }
function theight() {
    var d = document, b = d.body, e = d.documentElement;
    return Math.max(Math.max(b.scrollHeight, e.scrollHeight), Math.max(b.clientHeight, e.clientHeight))
}
function twidth() {
    var d = document, b = d.body, e = d.documentElement;
    return Math.max(Math.max(b.scrollWidth, e.scrollWidth), Math.max(b.clientWidth, e.clientWidth))
}

function getFullWidth() {
    var winWidth = 0;
    if (window.innerWidth) {
        winWidth = window.innerWidth;
    }
    else if ((document.body) && (document.body.clientWidth)) {
        winWidth = document.body.clientWidth;
    }
    //通过深入Document内部对body进行检测，获取窗口大小 
    if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) {
        winWidth = document.documentElement.clientWidth;
    }
    if (winWidth < 1024) {
        winWidth = 1024;
    }
    return winWidth;
}

function getFullHeight() {
    var screenHeight = document.body.scrollHeight;
    var winHeight;
    //获取窗口高度
    if (window.innerHeight) {
        winHeight = window.innerHeight;
    }
    else if ((document.body) && (document.body.clientHeight)) {
        winHeight = document.body.clientHeight;
    }

    //通过深入Document内部对body进行检测，获取窗口大小 
    if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) {
        winHeight = document.documentElement.clientHeight;
    }

    var divHeight = winHeight;
    if (screenHeight > winHeight) {
        divHeight = screenHeight;
    }
    //    if (divHeight < 768) {
    //        divHeight = 768;
    //    }
    return divHeight;
}
/**
**遮罩层显示
    
*/
function showDiv(idName) {
    var isExistLayer = false;
    for (var i = 0, len = tempPublicVal_public.wins.length; i < len; i++) {
        var winObj = tempPublicVal_public.wins[i];
        if (winObj.popWin == idName) {
            var layerId = winObj.layer;
            var $layerIdObj = $("#" + layerId);
            if ($layerIdObj.length > 0) {
                if ($layerIdObj.is(":hidden") == true) {
                    $layerIdObj.show();
                }
                isExistLayer = true;
                return;
            }
        }
    }

    var isIE = (document.all) ? true : false;
    // var isIE6 = isIE && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6);
    var isIE6 = isIE && !window.XMLHttpRequest;

    var layerIndex = ++tempPublicVal_public.layerIndex
    var layerId = "layer" + layerIndex;
    var layerzIndex = ++tempPublicVal_public.maxzIndex;

    var layer = document.createElement("div");
    layer.id = layerId;
    layer.style.width = layer.style.height = "100%";
    layer.style.position = !isIE6 ? "fixed" : "absolute";
    layer.style.top = layer.style.left = 0;
    layer.style.backgroundColor = "#000";
    layer.style.zIndex = layerzIndex;
    layer.style.opacity = "0.6";
    document.body.appendChild(layer);

    var divzIndex = ++tempPublicVal_public.maxzIndex;
    var newbox = document.getElementById(idName);
    newbox.style.zIndex = divzIndex;
    newbox.style.display = "block"
    newbox.style.position = !isIE6 ? "fixed" : "absolute";
    newbox.style.top = newbox.style.left = "50%";
    newbox.style.marginTop = -newbox.offsetHeight / 2 + "px";
    newbox.style.marginLeft = -newbox.offsetWidth / 2 + "px";

    tempPublicVal_public.wins.push({ popWin: idName, layer: layerId, layerIndex: tempPublicVal_public.layerIndex });

    //    var sel = document.getElementsByTagName("select");
    //    for (var i = 0; i < sel.length; i++) {
    //        sel[i].style.visibility = "hidden";
    //    }
    function layer_iestyle() {
        layer.style.width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth)
    + "px";
        layer.style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) +
    "px";
    }
    // lｉｅｈｕｏ．ｎｅｔ
    function newbox_iestyle() {
        newbox.style.marginTop = document.documentElement.scrollTop - newbox.offsetHeight / 2 + "px";
        newbox.style.marginLeft = document.documentElement.scrollLeft - newbox.offsetWidth / 2 + "px";
    }
    if (isIE) { layer.style.filter = "alpha(opacity=60)"; }
    if (isIE6) {
        layer_iestyle()
        newbox_iestyle();
        window.attachEvent("onscroll", function () {
            newbox_iestyle();
        })
        window.attachEvent("onresize", layer_iestyle)
    }
    layer.onclick = function () {
        //            newbox.style.display = "none"; layer.style.display = "none"; for (var i = 0; i < sel.length; i++) {
        //                sel[i].style.visibility = "visible";
        //            } 
    }
}

function hiddenDiv(idName) {
    var layerId = '';
    for (var i = 0, len = tempPublicVal_public.wins.length; i < len; i++) {
        var winObj = tempPublicVal_public.wins[i];
        if (winObj.popWin == idName) {
            layerId = winObj.layer;
            tempPublicVal_public.wins.splice(i, 1);
            break;
        }
    }
    $("#" + layerId).remove();
    //$("#layer").hide();
    $("#layer").remove();
    $("#" + idName).hide();

    tempPublicVal_public.maxzIndex -= 2;
    tempPublicVal_public.layerIndex -= 1;

    if ($("#messageErrorTagPara").val() == "1") {
        $('#CameraEx').show();
        $("#messageErrorTagPara").val("0");
    }
}